﻿using Gp.Scripts.Core;
using Gp.Scripts.GUI;
using System;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using NRFramework;
using UnityEngine.Events;

namespace Gp.Scripts.GUI
{
    public class CommonPopup : CommonPopupBase
    {
        private UnityAction onOkCallback;
        private UnityAction onCancelCallback;
        
        protected override void OnEnter() { }
        protected override void OnExit() { }

        public void Show(string title, string content, UnityAction okCallback = null, UnityAction cancelCallback = null)
        {
            mTxtTitle_TMPText.SetText(title);
            mTxtDesc_TMPText.SetText(content);
            
            onOkCallback = okCallback;
            onCancelCallback = cancelCallback;
        }

        protected override void OnClicked(Button button)
        {
            if (button == this.mBtnCancel_Button)
            {
                RemoveSelf(() => onCancelCallback?.Invoke());
            } 
            else if (button == this.mBtnConfirm_Button)
            {
                RemoveSelf(() => onOkCallback?.Invoke());
            }
        }
    }
}